package com.ck.controller.student;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import com.ck.domain.Student;
import com.ck.service.StudentService;

public class StudentHomeController extends AbstractController {
	
	private StudentService studentService;

	public void setStudentService(StudentService studentService) {
		this.studentService = studentService;
	}

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		Integer studentID = (Integer) request.getSession().getAttribute("studentID");
		Map model = new HashMap();

		Student student = studentService.gainStudent(studentID);
		
		model.put("student", student);
		
		return new ModelAndView("student/home",model);
	}

}
